#!/bin/bash

# 颜色定义
GREEN='\033[0;32m'
RED='\033[0;31m'
YELLOW='\033[0;33m'
NC='\033[0m' # No Color

echo -e "${YELLOW}开始测试 HTML解析器模块...${NC}"

# 运行所有测试
if [ "$1" == "--all" ]; then
    echo -e "${YELLOW}执行所有测试...${NC}"
    cargo test
elif [ "$1" == "--verbose" ]; then
    echo -e "${YELLOW}执行测试（详细模式）...${NC}"
    cargo test -- --nocapture
elif [ -n "$1" ]; then
    echo -e "${YELLOW}执行测试: $1${NC}"
    cargo test "$1"
else
    echo -e "${YELLOW}执行标准测试...${NC}"
    cargo test
fi

# 检查测试结果
if [ $? -eq 0 ]; then
    echo -e "${GREEN}所有测试通过!${NC}"
else
    echo -e "${RED}测试失败!${NC}"
    exit 1
fi

echo -e "${YELLOW}测试完成.${NC}"
